#!/bin/bash

echo "========================================"
echo "  语音增强对比平台 - 启动脚本"
echo "========================================"
echo ""

echo "[1/3] 检查依赖..."
if [ ! -d "node_modules" ]; then
    echo "📦 首次运行，正在安装依赖..."
    echo "这可能需要几分钟，请耐心等待..."
    echo ""
    npm install
    if [ $? -ne 0 ]; then
        echo "❌ 依赖安装失败，请检查网络连接"
        exit 1
    fi
    echo "✅ 依赖安装完成！"
    echo ""
else
    echo "✅ 依赖已安装"
    echo ""
fi

echo "[2/3] 创建必要的目录..."
if [ ! -d "uploads" ]; then
    mkdir -p uploads
    echo "✅ 创建 uploads 目录"
else
    echo "✅ uploads 目录已存在"
fi
echo ""

echo "[3/3] 启动服务..."
echo "🚀 正在启动前后端服务器..."
echo ""
echo "提示:"
echo "  - 前端: http://localhost:3000"
echo "  - 后端: http://localhost:3001"
echo "  - 按 Ctrl+C 停止服务器"
echo ""
echo "========================================"
echo ""

npm start

